/**
  ******************************************************************************
  * @file    cam.h
  * @author  Amaseing team
  * @version V1.0.0
  * @date    21-november-2013
  * @brief   Com
  *         
  ******************************************************************************  
  */ 
#ifndef _COM_H_
#define _COM_H_

/* Public includes -----------------------------------------------------------*/
#include <stm32f4xx.h>

/* Public defines ------------------------------------------------------------*/
#define COM_BUFFER_SIZE			(20)

enum eTYPES {
	TYPE_WALLS = 0x01,
    TYPE_TWO,
    TYPE_IMAGE,
	TYPE_START,
	TYPE_STOP,
	TYPE_MOTOR_SET,
	TYPE_FRONTLED_SET,
	TYPE_MAP,
	TYPE_OBJECT_FOUND,
	TYPE_RESET_COM,
	TYPE_MAX 			//if type is equal or higher, error
};
/* Public types --------------------------------------------------------------*/
typedef void(*comHandler)(uint16_t type, void* data, uint16_t size);

struct comPacketHeader {
	uint16_t type;
	uint16_t size;
};

struct comPacket {
	struct comPacketHeader header;
	uint8_t data[COM_BUFFER_SIZE];
};

/* Public functions ----------------------------------------------------------*/
// Init. The passed function is called when a packet is received.
void comInit(comHandler h);

// Write.
int comWrite(uint32_t type, void* data, uint32_t len);

#endif


